{extend name="public/world"}
{block name="title"}添加科目{/block}
{block name="style"}
<style type="text/css">
    .layui-form-label {width:110px;}
</style>
{/block}
{block name="container"}
<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin">
    <div class="layui-card" style="padding: 20px 0 0 0;height:400px;margin-bottom: 10px;">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label label-required">往来客户</label>
                <div class="layui-input-inline">
                    <select name="user_id" lay-filter="user_id" lay-verify="required" lay-search>
                        <option value="">请选择客户</option>
                        {volist name="users" id="user"}
                        <option value="{$user.id}">{$user.name}-{$user.phone}-{$user_types[$user.type]}</option>
                        {/volist}
                    </select>
                </div>
                <div class="layui-form-mid layui-word-aux">* 需提前在【基础数据】中维护供应商、代理商及客户信息</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">上级科目</label>
                <div class="layui-form-mid">{$sub.code}-{$sub.name}-{$sub.pname}</div>
            </div>
        </div>
        <div class="layui-form-item" id="codeBox">

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label label-required">结转标示</label>
            <div class="layui-input-block">
                <input type="radio" name="sys" value="0" title="不结转" checked>
                <input type="radio" name="sys" value="1" title="结转">
            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="LAY-front-submit" id="LAY-front-submit" value="确认">
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script id="codeView" type="text/html">
    <div class="layui-block">
        <label class="layui-form-label">应收科目</label>
        <div class="layui-input-block" style="width: 400px;">
            <input type="checkbox" name="like[1006]" title="应收账款"{{# if(d.ca==1) { }} checked{{# } }}>
            <input type="checkbox" name="like[2003]" title="预收账款"{{# if(d.cb==1) { }} checked{{# } }}>
        </div>
    </div>
    <div class="layui-block">
        <label class="layui-form-label">预付科目</label>
        <div class="layui-input-block" style="width: 400px;">
            <input type="checkbox" name="like[1008]" title="预付账款"{{# if(d.cc==1) { }} checked{{# } }}>
            <input type="checkbox" name="like[2009]" title="应付账款"{{# if(d.cd==1) { }} checked{{# } }}>
        </div>
    </div>
    <div class="layui-block">
        <label class="layui-form-label">其他科目</label>
        <div class="layui-input-block" style="width: 400px;">
            <input type="checkbox" name="like[1005]" title="其他应收款"{{# if(d.ce==1) { }} checked{{# } }}>
            <input type="checkbox" name="like[2004]" title="其他应付款"{{# if(d.cf==1) { }} checked{{# } }}>
        </div>
    </div>
</script>
<script>
    //JavaScript代码区域
    layui.use(['form', 'laytpl'], function() {
        var $ = layui.$
            , laytpl = layui.laytpl
            , form = layui.form;
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.iframeAuto(index);
        form.on('select(user_id)', function(data){
            var id = data.value; //得到被选中的值
            $.ajax({
                url:"{:url('/erp.BasicsSubject/public_user_code')}",
                data:{'id':id},
                type:"POST",
                dataType:"json",
                success:function(res){
                    if(res.code==1) {
                        var getTpl = codeView.innerHTML;
                        laytpl(getTpl).render(res.data, function(html){
                            $('#codeBox').html(html);
                        });
                        form.render();
                    }
                }
            });
        });
    });
</script>
{/block}